package com.smart.community.user.service;

/**
 * 验证码服务接口
 * 
 * @author Wu.Liang
 */
public interface CaptchaService {

    /**
     * 生成图形验证码
     * 
     * @return 验证码信息（包含图片和key）
     * @throws Exception 统一异常
     */
    CaptchaInfo generateImageCaptcha() throws Exception;

    /**
     * 验证图形验证码
     * 
     * @param captchaKey 验证码key
     * @param captcha 验证码
     * @return 是否验证通过
     * @throws Exception 统一异常
     */
    boolean verifyImageCaptcha(String captchaKey, String captcha) throws Exception;

    /**
     * 发送短信验证码
     * 
     * @param phone 手机号
     * @throws Exception 统一异常
     */
    void sendSmsCaptcha(String phone) throws Exception;

    /**
     * 验证短信验证码
     * 
     * @param phone 手机号
     * @param captcha 验证码
     * @return 是否验证通过
     * @throws Exception 统一异常
     */
    boolean verifySmsCaptcha(String phone, String captcha) throws Exception;

    /**
     * 发送邮箱验证码
     * 
     * @param email 邮箱
     * @throws Exception 统一异常
     */
    void sendEmailCaptcha(String email) throws Exception;

    /**
     * 验证邮箱验证码
     * 
     * @param email 邮箱
     * @param captcha 验证码
     * @return 是否验证通过
     * @throws Exception 统一异常
     */
    boolean verifyEmailCaptcha(String email, String captcha) throws Exception;

    /**
     * 验证码信息
     */
    class CaptchaInfo {
        private String key;
        private String image;
        private String captcha;

        public CaptchaInfo(String key, String image, String captcha) {
            this.key = key;
            this.image = image;
            this.captcha = captcha;
        }

        public String getKey() {
            return key;
        }

        public void setKey(String key) {
            this.key = key;
        }

        public String getImage() {
            return image;
        }

        public void setImage(String image) {
            this.image = image;
        }

        public String getCaptcha() {
            return captcha;
        }

        public void setCaptcha(String captcha) {
            this.captcha = captcha;
        }
    }
} 